import sun.audio.AudioPlayer;

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;

public class LaunchPage extends JPanel {
    LaunchPage(final JFrame jFrame) throws IOException {
        final JPanel launchPage = this;
        this.setLayout(null);

        AudioPlayer.player.start(MyMusic.zhutiqu);


        final JLabel Launchpage_start = new JLabel();
        Launchpage_start.setIcon(new ImageIcon(Images.Launchpage_start));
        Launchpage_start.setBounds(530,240,330,100);
        this.add(Launchpage_start);

        final JLabel Launchpage_aboutUS = new JLabel();
        Launchpage_aboutUS.setIcon(new ImageIcon(Images.Launchpage_aboutUS));
        Launchpage_aboutUS.setBounds(640,335,200,60);
        this.add(Launchpage_aboutUS);

        JLabel Launchpage_background = new JLabel();
        Launchpage_background.setIcon(new ImageIcon(Images.Launchpage_background));
        Launchpage_background.setBounds(0,-20,1000,666);
        this.add(Launchpage_background);

        Launchpage_start.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);

                launchPage.setVisible(false);
                jFrame.add(new RoleSelection(jFrame,launchPage));
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                super.mouseEntered(e);
                Launchpage_start.setIcon(new ImageIcon(Images.Launchpage_startbig));
                Launchpage_start.setBounds(522,240,330,100);
            }

            @Override
            public void mouseExited(MouseEvent e) {
                super.mouseExited(e);
                Launchpage_start.setIcon(new ImageIcon(Images.Launchpage_start));
                Launchpage_start.setBounds(530,240,330,100);
            }
        });

        Launchpage_aboutUS.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                launchPage.setVisible(false);
                jFrame.add(new AboutUS(jFrame,launchPage));
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                super.mouseEntered(e);
                Launchpage_aboutUS.setIcon(new ImageIcon(Images.Launchpage_aboutUSbig));
                Launchpage_aboutUS.setBounds(630,335,200,60);
            }

            @Override
            public void mouseExited(MouseEvent e) {
                super.mouseExited(e);
                Launchpage_aboutUS.setIcon(new ImageIcon(Images.Launchpage_aboutUS));
                Launchpage_aboutUS.setBounds(640,335,200,60);
            }
        });

    }



    public static void main(String[] args) throws IOException {
        JFrame jFrame = new JFrame();
        LaunchPage launchPage = new LaunchPage(jFrame);
        jFrame.add(launchPage);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.setSize(1000, 666);
        jFrame.setLocationRelativeTo(null);
        jFrame.setVisible(true);
    }
}
